package org.lq.his.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.lq.his.pojo.DoctorRankClass;
import org.lq.his.pojo.RegistrationChargeType;
import org.lq.his.service.RegistrationChargeTypeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/registrationChargeType")
public class RegistrationChargeTypeController {
	
	@Resource
	private RegistrationChargeTypeService registrationChargeTypeService;

	public void setRegistrationChargeTypeService(RegistrationChargeTypeService registrationChargeTypeService) {
		this.registrationChargeTypeService = registrationChargeTypeService;
	}
	@RequestMapping("/index")
	public String index()throws Exception{
		return "RegistrationChargeType/RegistrationChargeTypeIndex";
	}
	@RequestMapping(value="/RegistrationChargeTypeForm",method=RequestMethod.GET)
	public String RegistrationChargeTypeAdd()throws Exception{
		return "RegistrationChargeType/RegistrationChargeTypeForm";
	}
	@RequestMapping("/selectAll")
	@ResponseBody
	public List<RegistrationChargeType> selectAll()throws Exception{
		return registrationChargeTypeService.getAll();
	}
	@RequestMapping("/selectById")
	@ResponseBody
	public RegistrationChargeType selectById(Integer id)throws Exception{
		return registrationChargeTypeService.getById(id);
	}
	@RequestMapping("/list") 
	@ResponseBody
	public Map<String, Object> list(@RequestParam(defaultValue="1")Integer  page,@RequestParam(defaultValue="5")Integer  rows,@RequestParam(defaultValue="id") String sort,@RequestParam(defaultValue="asc") String order, RegistrationChargeType condition) throws Exception{
		
		Map<String, Object> map = new HashMap<>();
		int start = (page - 1)*rows;
		List<RegistrationChargeType> list = registrationChargeTypeService.getListByCondition(start, rows, condition, sort,order);
		int total = registrationChargeTypeService.getCountByCondition(condition);
		map.put("total", total);
		map.put("rows", list);
		
		return map;
	}
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> add(RegistrationChargeType registrationChargeType)throws Exception{
		Map<String, Object> map = new HashMap<>();
		registrationChargeTypeService.add(registrationChargeType);
		map.put("result", true);
		return map;
	}
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> edit(RegistrationChargeType registrationChargeType)throws Exception{
		Map<String, Object> map = new HashMap<>();
		registrationChargeTypeService.update(registrationChargeType);
		
		map.put("result", true);
		
		return map;
	}
	@RequestMapping("/view")
	@ResponseBody
	public RegistrationChargeType view(Integer id)throws Exception{
		return registrationChargeTypeService.getById(id);
	}
	@RequestMapping("/deleteRegistrationChargeType")
	@ResponseBody
	public Map<String, Object> delete(Integer[] ids)throws Exception{
		registrationChargeTypeService.deleteRegistrationChargeType(ids);
		Map<String, Object> map = new HashMap<>();
		map.put("result", true);
		return map;
	}
}
